package com.thermofisher.dsc.amanda.customer.controller;

import com.thermofisher.dsc.amanda.common.Query;
import com.thermofisher.dsc.amanda.common.crud.controller.AbsBaseController;
import com.thermofisher.dsc.amanda.common.tracking.TrackingAction;
import com.thermofisher.dsc.amanda.customer.service.CustomerService;
import com.thermofisher.dsc.amanda.model.constant.ActionEnum;
import com.thermofisher.dsc.amanda.model.dto.customer.CustomerDto;
import com.thermofisher.dsc.amanda.model.response.BaseResponse;
import com.thermofisher.dsc.amanda.model.response.DataResponse;
import java.util.Map;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author wenjie.yang on 1/3/2019.
 */
@RestController
@RequestMapping("/api/customer")
public class CustomerController extends AbsBaseController<CustomerService, CustomerDto> {
    @Override
    @PostMapping
    @TrackingAction(action = ActionEnum.SEARCH_CUSTOMER)
    public BaseResponse getList(@RequestBody Map<String, Object> params) {
        return service.getCustomers(new Query(params));
    }

    @PostMapping("/detail")
    @TrackingAction(action = ActionEnum.SELECTED_CUSTOMER)
    public BaseResponse getBySTNo(@RequestBody Map<String, Object> params) {
        DataResponse response = new DataResponse(service.getBySt(params.get("ship2NO").toString()));
        return response;
    }

}
